<!DOCTYPE html>
<!--suppress ALL -->
<html lang="en"  xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <link rel="shortcut icon" th:href="@{/chqimage/favicon.ico}" type="image/x-icon">
    <title>用户中心</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <link rel="stylesheet"  th:href="@{/chqcss/pingjia.css}">
    <script type="text/javascript"  th:src="@{/chqjs/jquery.min.js}"></script>
    <script type="text/javascript"  th:src="@{/chqjs/vue.min.js}"></script>
</head>
<body>
<!--顶部标题-->
<div id="head">
    <a href="my-mediate.html" class="return_img float_left"><img src="/chqimage/icon-fanh.png" alt=""></a>
    <p class="head_title">我的评价</p>
</div>
<div id="pingjia_box">
        <div class="pingjia_content">
            <textarea v-model="judged_detail" name="pingjia" class="pingjia" placeholder="输入调解评论..."></textarea>
        </div>
        <div class="tongyi">
            <div>是否认可调解结果</div>
            <div class="isChoice_box">
                <input type="checkbox" id="checkbox" >
                <label for="checkbox" class="labelbox"></label>
            </div>
        </div>
        <div class="pingjia_tijiao next_step" @click="addjudged" v-show="isShow">提交</div>
</div>
<script>
new Vue({
    el:'#pingjia_box',
    data:{
        judged_detail:'',
        isShow:'true'
    },
    mounted:function () {
        var _that = this;
        $.ajax({
            url:'/user/pjDetail',
            type:'get',
            datatype:'json',
            success:function (result) {
                console.log(result.judged_detail)
                if( result.judged_detail != '' && result.judged_detail != undefined){
                    _that.judged_detail = result.judged_detail;//显示已评价内容，隐藏提交按钮
                    _that.isShow = false;
                }else{
                    _that.isShow = true;
                }
            },
            error:function (err) {
                console.log(err);
            }
        })
    },
    methods:{
       addjudged:function () {
           var _that = this;
             if ($('#checkbox').is(':checked')) {//认可调解结果，提交评价
                 var _that = this;
                 if (_that.judged_detail.replace(/(^\s*)|(\s*$)/g, '') != '') {
                     var caseJudgedDetail = {
                         judged_detail: _that.judged_detail
                     };
                     judged_detail = JSON.stringify(_that.judged_detail);
                     $.ajax({
                         url: '/user/addJudged',
                         type: 'get',
                         contentType: 'application/json;charset=utf-8',
                         data: caseJudgedDetail,
                         datatype: 'json',
                         success: function (result) {
                             window.location.href = '/user/my-mediate?2';
                         },
                         error: function (err) {
                             console.log(err);
                         }
                     });
                 } else {//去掉前后空格
                     return false;
                 }
             } else {
                 return false;
             }
        }
    }
})

</script>

</body>
</html>